package cc.telecomdigital.tdstock.testcase;

import cc.telecomdigital.tdstock.StringUtils;

import junit.framework.Assert;
import android.test.AndroidTestCase;

public class RoundDownNumberTestCase extends AndroidTestCase
{
	public void testFiveCharsRule() throws Throwable
	{
		String tmp = "12.10420";
		Assert.assertEquals("12.10", StringUtils.roundDownFormatToFiveCharsRule(tmp));
	}
	public void testSixCharsRule() throws Throwable
	{
		String tmp = "12.10420";
		Assert.assertEquals("12.104", StringUtils.roundDownFormatToSixCharsRule(tmp));
	}
	public void testNCharsRule() throws Throwable
	{
		String tmp = "0.1";
		Assert.assertEquals("0.10", StringUtils.roundDownFormatToNCharsRule(tmp, 4));
	}
	public void testAutoCharsRule() throws Throwable
	{
		String tmp = "0.1";
		Assert.assertEquals("0.100", StringUtils.roundDownFormatToAutoCharsRule(tmp, 3, true));
	}
	public void testAutoCharsRuleCutZero() throws Throwable
	{
		String tmp = "5.335";
		String s = StringUtils.roundDownFormatToAutoCharsRule(tmp, 2, true, true);
		System.out.println(s);
		Assert.assertEquals("5.33", s);
	}
	public void testIntegerCharsRule() throws Throwable
	{
		String tmp = "1521.100";
		Assert.assertEquals("1521", StringUtils.roundDownInteger(tmp));
	}
	public void testAutoIntegerCharsRule() throws Throwable
	{
		String tmp = "152131.100";
		Assert.assertEquals("15213", StringUtils.roundDownNCharsInteger(tmp, 5));
	}
}
